<script setup lang="tsx">
interface Emits {
  (e: 'search', model: any): void;
  (e: 'reset', model: any): void;
}

const emit = defineEmits<Emits>();

const model = defineModel<any>('model', { required: true });

function search() {
  emit('search', model.value);
}

function reset() {
  model.value.matNo = null;
  model.value.state = null;
  model.value.auditingState = null;
  emit('reset', model.value);
}
</script>

<template>
  <ACard :title="null" :bordered="false" class="search-card card-wrapper">
    <AForm
      :model="model"
      :label-col="{
        span: 5,
        md: 7
      }"
      class="search-form"
    >
      <div class="w-full flex">
        <ARow :gutter="[15, 8]" wrap class="w-full">
          <ACol :span="24" :md="12" :lg="6" :xl="8" :xxl="4">
            <AFormItem label="物料编号" name="matNo" class="m-0" :label-col="{}">
              <AInput
                v-model:value="model.matNo"
                placeholder="请输入物料编号"
                class="min-form-control"
                allow-clear
                autocomplete="off"
                @keypress.enter="search"
              />
            </AFormItem>
          </ACol>
          <ACol :span="24" :md="12" :lg="6" :xl="8" :xxl="4">
            <AFormItem label="过期状态" name="state" class="m-0" :label-col="{}">
              <ASelect v-model:value="model.state" placeholder="请选择状态" class="min-form-control" allow-clear>
                <ASelectOption value="1">正常</ASelectOption>
                <ASelectOption value="2">即将过期</ASelectOption>
                <ASelectOption value="3">已过期</ASelectOption>
                <ASelectOption value="4">库存不足</ASelectOption>
              </ASelect>
            </AFormItem>
          </ACol>
          <ACol :span="24" :md="12" :lg="6" :xl="8" :xxl="4">
            <AFormItem label="审核状态" name="auditingState" class="m-0" :label-col="{}">
              <ASelect
                v-model:value="model.auditingState"
                placeholder="请选择状态"
                class="min-form-control"
                allow-clear
              >
                <ASelectOption value="1">未审核</ASelectOption>
                <ASelectOption value="2">已审核</ASelectOption>
              </ASelect>
            </AFormItem>
          </ACol>
          <div class="flex">
            <AFormItem class="m-0">
              <div class="w-full flex-y-center justify-end gap-12px">
                <AButton type="primary" ghost class="mini-btn" @click="search">
                  <template #icon>
                    <icon-ic-round-search class="align-sub text-icon" />
                  </template>
                  <span class="ml-3px">{{ $t('common.search') }}</span>
                </AButton>

                <AButton class="mini-btn" @click="reset">
                  <template #icon>
                    <icon-ic-round-refresh class="align-sub text-icon" />
                  </template>
                  <span class="ml-3px">{{ $t('common.reset') }}</span>
                </AButton>
              </div>
            </AFormItem>
          </div>
        </ARow>
      </div>
    </AForm>
  </ACard>
</template>

<style></style>
